package com.qf.service2.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.domain2.Student;
import com.qf.mapper2.StudentMapper;
import com.qf.mapper2.StudentMapper2;
import com.qf.service2.StudentServcie;
import com.qf.utils.MapperUtils;

import java.util.List;

public class StudentServiceImpl2 implements StudentServcie {
    @Override
    public List<Student> findAll() {

        StudentMapper2 studentMapper = MapperUtils.getMapper(StudentMapper2.class);

        List<Student> students = studentMapper.findAll();

        MapperUtils.close();

        return students;
    }

    @Override
    public PageInfo<Student> findPage(int pageNum, int size) {
        //设置分页参数
        PageHelper.startPage(pageNum,size);

        //执行mapper查询
        StudentMapper2 studentMapper = MapperUtils.getMapper(StudentMapper2.class);

        List<Student> students = studentMapper.findAll();

        MapperUtils.close();

        //将查询到的结果封装成PageInfo返回
        return new PageInfo<>(students);
    }
}
